String.substring(start,{end})
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
myString.substring(start {, end})

Arguments
start: An integer. The position of 1st character in myString to form substring. If start is a negative number, the starting position is determined from the end of the string, where the -1 is the last character.

end: An optional integer that is one index value higher than the last character of the string that you want to be extracted. Acceptable values are 1 through String.length. If this argument is not provided, the substring method will use string.length. Negative values for this argument default to a value of 0.

Returns
Nothing.

Description
Method: Returns the substring formed from the characters in a string from the index specified in the start argument through the number of characters specified in the end argument. If the end argument is not provided then the end of this substring will be the last character in the string. If the value specified in the start argument is greater than the value specified in the end argument, then these values are swapped before the method is executed. If the value of the end argument is a negative number, then a value of 0 is used in its place.

Sample
onLoad() {
    str = "SWiSHmax is Great!";
    trace(str.substring(0,5));
}
// displays "SWiSH" In
 the Debug window

onLoad() {
    str = "Swishmax is Great";
    trace(str.substring(0,8));
}
// displays "SWiSHmax" In
 the Debug window